package org.example.likou150.array;
/* 跳跃游戏
* https://leetcode.cn/problems/jump-game/?envType=study-plan-v2&envId=top-interview-150
* */
public class CanJump {
    public static void main(String[] args) {

    }

    public boolean canJump(int[] nums) {
        int max=0;
        for(int i=0; i<nums.length; i++){
            if(max >= i){
                max=Math.max(i+nums[i], max);
                if (max >= nums.length - 1) return true;
            }
        }
        return nums.length <= max+1;
    }
}
